Methods for coding moving image data to compress have been conventionally known. In such a method, prediction, transform and entropy coding are typically performed in units of rectangular blocks of a specific size such as 8 pixels×8 pixels. For example, in AVC/H.264, a coded block is predicted, two-dimensional transform coefficients resulting from DCT and quantization are zigzag-scanned into one-dimensional data, and furthermore, variable length coding tables are adaptively switched based on the number of DCT coefficients in adjacent blocks to code the transform coefficients.
Japanese Patent No. 3337583 (U.S. Pat. No. 5,650,782) provides for improvement of the coding efficiency by scanning two-dimensional transform coefficients resulting from transform and quantization, selecting one of a plurality of variable length coding tables optimized in terms of frequencies of runs and levels according to a quantization parameter.
In an image processing LSI (large-scale integration) or the like used in a device, a memory band width and the like are limited because of various restrictions such as circuit layout, and a coded block may thus need to have a small size such as 2 pixels×2 pixels. In AVC/H.264 and Japanese Patent No. 3337583, however, since transform coefficients are converted into one-dimensional data in units of a coded block, the number of runs does not increase when the size of the coded block is small, and the coding efficiency does not necessarily improved.
Moreover, since the variable-length coding tables are switched in units of a block in Japanese Patent No. 3337583, coding using the relation between the transform coefficients and the spatial frequencies cannot be performed, and the coding efficiency is not necessarily improved.